<template>
  <div class="goods-item" @click="goodsItemClick">
    <div class="img">
      <img :src="showImg" alt="" />
    </div>
    <div class="title">
      <h4>{{ goodsItem.title }}</h4>
    </div>
    <div class="des">
      <span class="price">{{ showPrice }}</span>
      <span class="collect"
        ><img src="~assets/img/common/collect.svg" alt="" />
        {{ goodsItem.cfav }}
      </span>
    </div>
  </div>
</template>

<script>
export default {
  name: "GoodsListItem",
  props: {
    goodsItem: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  computed: {
    showImg() {
      return this.goodsItem.image || this.goodsItem.show.img;
    },
    showPrice() {
      return this.goodsItem.orgPrice || this.goodsItem.price;
    },
  },
  methods: {
    goodsItemClick() {
      // console.log("tiahzuna");
      // 点击goodsItem传递iid参数
      this.$router.push("/detail/" + this.goodsItem.iid);
    },
  },
};
</script>

<style scoped>
.goods-item {
  width: 45%;
  padding-bottom: 25px;
}

.goods-item img {
  width: 100%;
  /* height: 260px; */
  border-radius: 5px;
}
.goods-item .title {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 15px;
  font-weight: 700;
  margin: 10px 5px;
}
.goods-item .des {
  font-size: 14px;
  text-align: center;
}

.des .price {
  color: var(--color-tint);
  padding-right: 10px;
}
.des .collect img {
  width: 10%;
  vertical-align: bottom;
}
</style>
